<?php
//include_once("core.inc.php");


class df_table_info{
	//a foregin key column can be either linked to a databse name or a page parent id
	private $table, $foreign_keys,$listing_fields, $primary_key='id',$query_postfix='';
	// note that because the first foreign key field refers to the associated document's parent, 
	// it doesn't really matter, because the foreign key must be the document itself
	// column holds doc_id, this field holds doc_id_id?!
	function __construct($table, $foreign_keys='',$summary_fields=''){
		$this->table = $table;
		$this->foreign_keys = $foreign_keys;
		$this->summary_fields = $summary_fields;
	}
	
	function setPrimaryKey($string){$this->primary_key = $string;}
	// function setQueryPostfix($query_postfix){$this->query_postfix = $query_postfix;}  //should be implemented on M2M/O2M scripts before being enabled here
	
	function getTableName(){return $this->table;}  // for example: office_contacts 
	function getForeignKeys(){return $this->foreign_keys;} //for example: 'office_id' => '22'.  
	function getSummaryFields(){return $this->summary_fields;} // " name, email, phone, status
	function getPrimaryKey(){return $this->primary_key;}
}

		
		//create the M2M products table for an office:
		//todo: update these so that summary_field is key => value
		$products = new df_table_info('products', '', array('title' => 'Product Name') );  //prdoucts have no foreign key
		$products->setPrimaryKey('productId');
		
		$productTypes = new df_table_info('productTypes', '', array('name' => 'Product Type'));  //types have no foreign key
		$productTypes->setPrimaryKey('productTypeId');
		
		// => $e->params['id']
		$OPJoin = new df_table_info('officeProduct', array('officeId', 'productID' => $products, 'productTypeId' => $productTypes));

echo serialize($OPJoin);
?>
